package com.autosalon.model;


import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name = "ZAKAZNIK")
public class Zakaznik implements Serializable, IModelClass{
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	@Column(name = "MENO", length=20)
	private String meno;
	
	@Column(name = "PRIMENI", length=40)
	private String primeni;
	
	@Column(name = "MOBIL", length=13)
	private String mobil;
	
	@Column(name = "EMAIL", length=50)
	private String email;
	
	@Column(name = "POZNAMKA", length=400)
	private String poznamka;
	
	@Column(name="HESLO", length=25, nullable=false)
	private String password;
	
	@OneToMany(mappedBy="id", cascade = CascadeType.ALL, targetEntity=Adresa.class)
	@JoinColumn(name = "ZAKAZNIK_ID")
	private List<Adresa> adresy;
	
	@OneToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name="ID_ROLE")
	private Role role;
	
	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "ID_ZAKAZNIK")
	private List<Objednavka> zadane_objednavky;

	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "ID_SELLER")
	private List<Objednavka> vybaveny_objednavky;

	@Override
	public Long getId() {
		return id;
	}

	public String getMeno() {
		return meno;
	}

	public void setMeno(String meno) {
		this.meno = meno;
	}

	public String getPrimeni() {
		return primeni;
	}

	public void setPrimeni(String primeni) {
		this.primeni = primeni;
	}

	public String getMobil() {
		return mobil;
	}

	public void setMobil(String mobil) {
		this.mobil = mobil;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPoznamka() {
		return poznamka;
	}

	public void setPoznamka(String poznamka) {
		this.poznamka = poznamka;
	}

	public List<Adresa> getAdresy() {
		return adresy;
	}

	public void setAdresy(List<Adresa> adresy) {
		this.adresy = adresy;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public List<Objednavka> getZadane_objednavky() {
		return zadane_objednavky;
	}

	public void setZadane_objednavky(List<Objednavka> zadane_objednavky) {
		this.zadane_objednavky = zadane_objednavky;
	}

	public List<Objednavka> getVybaveny_objednavky() {
		return vybaveny_objednavky;
	}

	public void setVybaveny_objednavky(List<Objednavka> vybaveny_objednavky) {
		this.vybaveny_objednavky = vybaveny_objednavky;
	}

        @Override
        public String toString() {
           return this.getMeno() + " " + this.getPrimeni() + ", " + this.getEmail() + ", " + this.getMobil(); 
        }
	
	

}
